//
//  HospitalInCoureseVC.m
//  HandheldELearn
//
//  Created by wsj2015 on 16/7/11.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "HospitalInCoureseVC.h"

#import "InhospitallCourseCell.h"
#import "HELTypeChooseVC.h"
#import "HELBaseViewVC.h"
#import "HELCourseDetailVC.h"
@interface HospitalInCoureseVC ()<UICollectionViewDataSource,UICollectionViewDelegate,UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *typeTF;
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation HospitalInCoureseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    
    self.title = @"院内课程";
    self.view.backgroundColor = kAppBg;
    
    UICollectionViewFlowLayout *layout =[[UICollectionViewFlowLayout alloc] init];
    self.collectionView =[[UICollectionView alloc] initWithFrame:CGRectMake(0,51 +64, kScreenWidth, kScreenHeight  -51 -64) collectionViewLayout:layout];
    self.collectionView.backgroundColor =[UIColor whiteColor];
    CGFloat w = (kScreenWidth -24)/2;
    CGFloat h =159;
    self.collectionView .delegate = self;
    self.collectionView.dataSource = self;
    layout.itemSize =CGSizeMake(w, h);
    layout.sectionInset =UIEdgeInsetsMake(8, 8, 10, 8);
    layout.minimumInteritemSpacing = 4;
    layout.minimumLineSpacing = 8;
    [self.view addSubview:self.collectionView];
    [self.collectionView registerNib:[UINib nibWithNibName:@"InhospitallCourseCell" bundle:nil] forCellWithReuseIdentifier:@"InhospitallCourseCell"];
    
    [self setNavToBlue];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}



- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    //    return [self.dataArray count];
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    //    NSArray *arr = self.dataArray[section];/
    
    return 5;
    //    return arr.count;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    
    //进入另一个界面选择
    
    HELTypeChooseVC *vc =[HELTypeChooseVC new];
    vc.callBack = ^(NSString *departmentNo,NSString *departmentName){
    
   
    };

    [self presentViewController:  [[UINavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
    
    
    return NO;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    //    NSDictionary *obj = self.dataArray[indexPath.section];
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"InhospitallCourseCell"
                                                                           forIndexPath:indexPath];
    //
    //    cell.textLabel.text = [[obj allValues] firstObject];
    
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    HELCourseDetailVC *vc =[HELCourseDetailVC new];
    [self.navigationController pushViewController:vc animated:YES];
    

}

@end
